package wpmp.security.mgr.base;

import wpmp.extjs3.data.Page;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;

/**
 * 所有Action的抽象基类
 * 
 * <pre>
 * 1.定义了对Preparable,ModelDriven接口的使用
 * 2.返回值的命名
 * 3.设置当前系统登录用户
 * </pre>
 * 
 * @author Wayne.Wang<5waynewang@gmail.com>
 * @since 10:30:17 AM Dec 21, 2012
 */
public abstract class BaseAction<T> extends ActionSupport implements ModelDriven<T>, Preparable {

	private static final long serialVersionUID = 1L;

	public static final String LIST = "list";// 列表
	public static final String VIEW = "view";// 查看，只读
	public static final String DELETE = "delete";// 删除
	public static final String INSERT = "insert";// 新增
	public static final String UPDATE = "update";// 更新
	public static final String EXPORT = "export";// 导出
	public static final String IMPORT = "import";// 导入
	public static final String DOWNLOAD = "download";// 下载
	public static final String UPLOAD = "upload";// 上传

	protected T entity;

	protected Page page;
	// 窗口ID，用于弹出窗口
	protected String winId;
	// 当前功能项的位置
	protected String position;

	public String getWinId() {
		return winId;
	}

	public void setWinId(String winId) {
		this.winId = winId;
	}

	public String getPosition() {
		return position;
	}

	public void setPosition(String position) {
		this.position = position;
	}

	public Page getPage() {
		return page;
	}

	public void setPage(Page page) {
		this.page = page;
	}

	@Override
	public String execute() throws Exception {
		return list();
	}

	public String list() throws Exception {
		return LIST;
	}

	public String input() throws Exception {
		return INPUT;
	}

	public String view() throws Exception {
		return VIEW;
	}

	@Override
	public void prepare() throws Exception {
	}
}
